<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<link rel="stylesheet" type="text/css" href="<s:url value='/CSS/back/productType/productType_list.css'/>"/>
<table class="view-product-types"> 
  <caption>View Product Types</caption>
  <tr class="tr1">
    <td class="td1">TypeId</td>
    <td class="td2">Name</td>
    <td class="td3">Sub-Types</td>
    <td class="td4">Add Sub-Type</td>
    <td class="td5">Parent Type</td>
    <td class="td6">Edit</td>
    <td class="td7">Delete</td>
  </tr>
  <s:iterator var="productType" value="pagination.list" status="stat">
    <tr class="tr2" id="row_<s:property value='#stat.index'/>"
          onmouseover="onChange('row_<s:property value='#stat.index'/>', 0)"
          onmouseout="onChange('row_<s:property value='#stat.index'/>', 1)">
      <td class="td1"><s:property value="#productType.typeId"/></td>
      <td class="td2">
        <s:property value="#productType.name"/>
      </td>
      <td class="td3">
        <s:if test="#productType.children == null || #productType.children.isEmpty()">
          No Sub-Types
        </s:if>
        <s:else>
          <s:a action="productTypeAction_list" namespace="/back/productType">
            <s:param name="parentTypeId" value="#productType.typeId"/>
            Having&nbsp;<s:property value="#productType.children.size"/>&nbsp;Sub-Types
          </s:a>
        </s:else>
      </td>
      <td class="td4">
        <s:a action="productTypeAction_add" namespace="/back/productType">
          <s:param name="parentTypeId" value="#productType.typeId"/>Add 
        </s:a>
      </td>
      <td class="td5">
        <s:if test="#productType.parent != null">
          <s:property value="#productType.parent.name"/>
        </s:if>
        <s:else>
          No Parent Type
        </s:else>
      </td>
      <td class="td6">
        <s:a action="productTypeAction_edit" namespace="/back/productType">
          <s:param name="productType.typeId" value="#productType.typeId"/>
          Edit
        </s:a>
      </td>
      <td class="td7">
        <s:a action="productTypeAction_delete" namespace="/back/productType">
          <s:param name="productType.typeId" value="#productType.typeId"/>
          Delete
        </s:a>
      </td>
    </tr> 
  </s:iterator>  
</table>
<s:url action="productTypeAction_list" namespace="/back/productType" var="first">
  <s:param name="pageNo" value="1"/>
  <s:param name="parentTypeId" value="parentTypeId"/>
</s:url>
<s:url action="productTypeAction_list" namespace="/back/productType" var="previous">
  <s:param name="pageNo" value="pagination.pageNo - 1"/>
  <s:param name="parentTypeId" value="parentTypeId"/>
</s:url>
<s:url action="productTypeAction_list" namespace="/back/productType" var="next">
  <s:param name="pageNo" value="pagination.pageNo + 1"/>
  <s:param name="parentTypeId" value="parentTypeId"/>
</s:url>
<s:url action="productTypeAction_list" namespace="/back/productType" var="last">
  <s:param name="pageNo" value="pagination.lastPageNo"/>
  <s:param name="parentTypeId" value="parentTypeId"/>
</s:url>
<s:include value="/WEB-INF/JSP/pagination.jsp"/>
<script type="text/javascript" src="<s:url value='/JS/jquery-1.7.2.min.js'/>"></script>
<script type="text/javascript" src="<s:url value='/JS/common.js'/>"></script>